<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org" lang="">
<head>
    <meta charset="utf-8">
    <title>Вход</title>
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet"
          integrity="sha384-QWTKZyjpPEjISv5WaRU9OFeRpok6YctnYmDr5pNlyT2bRjXh0JMhjY6hW+ALEwIH" crossorigin="anonymous">
    <style>
        body {
            height: 100vh;
            display: flex;
            align-items: center;
            justify-content: center;
        }

        form {
            max-width: 330px;
            padding: 15px;
            margin: auto;
        }

        .reg {
            margin-top: 10px;
        }
    </style>
</head>
<body>
<div th:if="${#httpServletRequest.getUserPrincipal()} == null">
    <form class="form-signin" method="POST" th:action="@{/login}">
        <h2 class="mb-3 font-weight-normal">Вход в систему</h2>
        <div class="form-label-group reg">
            <input name="username" type="text" id="inputUsername" class="form-control" placeholder="Имя пользователя"
                   autofocus="true" required>
        </div>
        <div class="form-label-group reg">
            <input name="password" type="password" id="inputPassword" class="form-control" placeholder="Пароль"
                   required>
        </div>
        <button class="btn btn-lg btn-primary btn-block reg" type="submit">Войти</button>
        <p class="mt-3 text-center">
            <a th:href="@{/registration}">Зарегистрироваться</a>
        </p>
    </form>
</div>
<div th:if="${#httpServletRequest.getUserPrincipal()} != null">
    <script th:inline="text">
        /*<![CDATA[*/
        window.location.href = '/index.html';
        /*]]>*/
    </script>
</div>

<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js"
        integrity="sha384-YvpcrYf0tY3lHB60NNkmXc5s9fDVZLESaAA55NDzOxhy9GkcIdslK1eN7N6jIeHz"
        crossorigin="anonymous"></script>
</body>
</html>